<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Profile extends BIT_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function __construct()
	{
		parent::__construct();
		$this->header_views = array('common/header');
		$this->footer_views = array('common/footer');
	}

	public function index($slug)
	{
		$company = $this->db->query("SELECT *, c.name AS companyname, b.name AS branch FROM company AS c ".
			" JOIN branches AS b ON (b.id = c.branch) ".
			" WHERE slug='$slug' LIMIT 1 ")->result();

		if(count($company) > 0)
		{
			$c=$company[0];

			$this->view_data = array(
				//"logotype" => "http://www.twifyindustries.com/images/twify_logo.png",
				"companyName" => mb_strtoupper($c->companyname),
				"description" => $c->short_desc,
				"attributes" => array(
					"Namn"		=> $c->companyname,
					"Org.nr"	=> $c->orgnr,
					"Adress"	=> $c->address,
					"Bransch"	=> $c->branch,
					"Hemsida"	=> $c->homepage,
					"Telefon"	=> $c->phone,
					"Epost"		=> $c->email
				)
			);

			$this->v('pages/profile');
		}
		else $this->v('404');
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */